//
//  Min-base.swift
//  soapp_Example
//
//  Created by zhu xietong on 2018/3/1.
//  Copyright © 2018年 CocoaPods. All rights reserved.
//

import Foundation
import AsyncDisplayKit

extension ASDisplayNode{
    public func fastLayoutSpec(_spec:_Spec) -> ASLayoutSpec{
        let spec_Nodes = _spec.specAndNodes
        //        subNodes = spec_Nodes.1
        
        var layout = ASLayoutSpec()
        let __spec = spec_Nodes.0
        switch __spec {
        case .node(let node):
            layout = ASWrapperLayoutSpec(layoutElement: node)
        case .spec(let _spec):
            layout = _spec
        }
        return layout
    }
}

//extension ASViewController{
//    public func fastLayoutSpec(_spec:_Spec) -> ASLayoutSpec{
//        let spec_Nodes = _spec.specAndNodes
//        //        subNodes = spec_Nodes.1
//
//        var layout = ASLayoutSpec()
//        let __spec = spec_Nodes.0
//        switch __spec {
//        case .node(let node):
//            layout = ASWrapperLayoutSpec(layoutElement: node)
//        case .spec(let _spec):
//            layout = _spec
//        }
//        return layout
//    }
//}

//public class MinFlex {
//    public weak var owner:ASDisplayNode? = nil
//
//
//    public var subNodes:[ASDisplayNode] = [ASDisplayNode]()
//    {
//        didSet{
////            if let father = owner{
////                for one in subNodes
////                {
////                    father.addSubnode(one)
////                }
////            }
//        }
//    }
//
//    public var spec:_Spec = _Spec.node(ASDisplayNode())
//    {
//        didSet{
//
//            let spec_Nodes = spec.specAndNodes
//            subNodes = spec_Nodes.1
//
//            let __spec = spec_Nodes.0
//            switch __spec {
//            case .node(let node):
//                self.layout = ASWrapperLayoutSpec(layoutElement: node)
//            case .spec(let _spec):
//                self.layout = _spec
//            }
//        }
//    }
//
//    public var layout:ASLayoutSpec = ASLayoutSpec()
//
////    public var layout:ASLayoutSpec{
////        get{
////            return spec.laySpec
////        }
////    }
//
//}
//
//
//extension ASDisplayNode
//{
//
//    private struct MinAssociatedKeys {
//        static var miniSpec = "MinAssociatedKeys.miniSpec"
//    }
//
//    public var mf:MinFlex{
//        get {
//            if let obj = __extention.object(forKey: MinAssociatedKeys.miniSpec) as? MinFlex
//            {
//                return obj
//            }
//            let obj = MinFlex()
//            obj.owner = self
//            self.mf = obj
//            return obj
//        }
//        set {
//            __extention[MinAssociatedKeys.miniSpec] = newValue
////            objc_setAssociatedObject(self, &MinAssociatedKeys.miniSpec, newValue, objc_AssociationPolicy.)
//        }
//    }
//
//
//
//
//}
//


